#include<iostream>
#include<unistd.h>
#include<vector>
#include<pthread.h>

using namespace std;

#define NUM 10

void *threadRoutine(void *args)
{
    int i = 0;
    while(i < 10)
    {
        cout << "pid: " << getpid() << ", ";
    }
    return nullptr;
}

int main()
{
    vector<pthread_t> tids;
    pthread_t tid;
    for(int i = 0; i < NUM; i++)
    {
        pthread_create(&tid, nullptr, threadRoutine, nullptr);
        tids.push_back(tid);
    }

    for(int i = 0; i < tids.size(); i++)
    {
        pthread_join(tids[1], nullptr);
    }

    return 0;
}